// /stores/modules/test.js
import { defineStore } from "pinia";

export const useAuthStore = defineStore("auth", {
	state: () => ({
		user: {
			account: {},
			api_status: null,
			avatar: "",
			balance: 0.0,
			commission: 0.0,
			consumption: 0.0,
			id: 0,
			invite_code: 0,
			level: 0,
			level_name: "",
			substation: [],
			trade_password: null,
			trade_password_scene: [],
			trade_password_status: true,
			username: ""
		},
		token: "",
		theme: {
			themeColor: "#2018B8",
			backgroundColor: "linear-gradient(to bottom, #cecbeb, #f1f4f9)"
		},
		config: {
			banner: [],
			customer_login_captcha: false,
			logo: "",
			module: [],
			name: "",
			register: "",
			register_bind: "",
			register_need_invite_code: "",
			short_name: ""
		}
	}),
	actions: {
		getToken() {
			return this.token;
		},
		setToken(newToken : string) {
			this.token = newToken;
		},
		getUser() {
			return this.user;
		},
		setUser(userData : any) {
			this.user = userData;
		},
		getTheme() {
			return this.theme;
		},
		setTheme(themeData : any) {
			this.theme = themeData;
		},
		getConfig() {
			return this.config;
		},
		setConfig(dataConfig : any) {
			this.config = dataConfig;
		}
	},
	persist: {
		storage: {
			// 修改存储方式
			getItem: uni.getStorageSync,
			setItem: uni.setStorageSync
		}
	}
});